﻿using SkiaSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SkiaSharpWinForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void skControl1_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
        {
            var imageInfo = e.Info;
            var surface = e.Surface;

            // 获得画布
            var canva = surface.Canvas;
            var skPoint = new SKPoint(imageInfo.Width / 2, imageInfo.Height / 2);
            var skPaint = new SKPaint()
            {
                Color = SKColors.Black,
                IsAntialias = true,
                Style = SKPaintStyle.StrokeAndFill,
                TextAlign = SKTextAlign.Center,
                TextSize = 36
            };

            canva.DrawText("Hello word!", skPoint, skPaint);
            canva.DrawLine(new SKPoint(10, 10), new SKPoint(imageInfo.Width - 10, 10), new SKPaint() { Color = SKColors.Red, IsAntialias = true, Style = SKPaintStyle.StrokeAndFill,TextSize=48 });
        }
    }
}
